#pragma once
//========================================================================
// BaseScriptComponent.h - Component for exposing actors to Lua
//========================================================================

#include "ScriptComponentInterface.h"
#include "LuaPlus/LuaPlus.h"


//---------------------------------------------------------------------------------------------------------------------
// BaseScriptComponent class
//---------------------------------------------------------------------------------------------------------------------
class BaseScriptComponent : public ScriptComponentInterface
{
	std::string m_scriptObjectName;
    std::string m_constructorName;
    std::string m_destructorName;

	LuaPlus::LuaObject m_scriptObject;
    LuaPlus::LuaObject m_scriptConstructor;
	LuaPlus::LuaObject m_scriptDestructor;
	
public:
	static const char* gp_name;
	virtual const char* VGetName() const {return gp_name;}

	BaseScriptComponent();
	virtual ~BaseScriptComponent();
	virtual bool VInit(TiXmlElement* p_data);
    virtual void VPostInit();
    virtual TiXmlElement* VGenerateXML();
	
	static void RegisterScriptFunctions();
	static void UnregisterScriptFunctions();
	
private:
	void CreateScriptObject();
	
	// component script functions
	LuaPlus::LuaObject GetActorId();
	
	// physics component script functions
	LuaPlus::LuaObject GetPos();
    void SetPos(LuaPlus::LuaObject newPos);
    LuaPlus::LuaObject GetLookAt() const;
    float GetYOrientationRadians() const;
	void RotateY(float angleRadians);
	void SetPosition(float x, float y, float z);
	void LookAt(Vector3 target);
    void Stop();
};

